import {request} from '@inbiz/utils';

export type IModelList = {
  Name: string;
  ID: string;
  Relations?: {
    ta: string;
    tid: string;
  }[];
}[];

// 查询数据列表
export async function dropDownListData({
  appId,
  queryKey,
  ids,
}: {
  appId: string;
  queryKey: string;
  ids: string;
}): Promise<
  {
    Text: string;
    Value: string;
    Id: string;
    Key: string;
  }[]
> {
  return await request.get(
    `/inbiz/api/services/modelengine/v${InbizConfig.API_VERSION}/control/dropDownListData/${appId}?ids=${ids}&queryKey=${queryKey}`,
  );
}

type IPageList = {
  OutId: string;
  Route: string;
}[];
// 获取站点下 所有页面
export async function getPageList(appId: string): Promise<IPageList> {
  return await request(
    `/inbiz/api/services/engines/v${InbizConfig.API_VERSION}/page/loadPageTreeList`,
    {
      params: {
        appId,
        version: InbizConfig.API_VERSION,
        isDevelopLatest: true,
      },
    },
  );
}
